# for循环
# 第一种方式
for row in range(1, 10):
    for col in range(1, row + 1):  # 列最多等于行
        print('{}*{}={:<4}'.format(row, col, row * col), end='')
    print('')
print('-' * 80)

# 第二种方式
for row in range(9, 0, -1):
    for col in range(1, row + 1):  # 列最多等于行
        print('{}*{}={:<4}'.format(row, col, row * col), end='')
    print('')
print('-' * 80)

# 第三种方式
for row in range(9, 0, -1):
    for i in range(1, row):
        print(' ' * 8, end='')
    for col in range(10 - row, 0, -1):
        print('{}*{}={:<4}'.format(col, row, row * col), end='')
    print('')
print('-' * 80)

# 第四种方式
for row in range(9, 0, -1):
    for i in range(9 - row, 0, -1):
        print(' ' * 8, end='')
    for col in range(row, 0, -1):
        print('{}*{}={:<4}'.format(col, row, row * col), end='')
    print('')
print('-' * 80)

# while循环
row = 1
while row <= 9:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(col, row, row * col), end='')
        col += 1
    row += 1
    print('')
print('-' * 80)

# 第二种方式
row = 9
while row >= 1:
    col = 1
    while col <= row:
        print('{}*{}={:<4}'.format(col, row, row * col), end='')
        col += 1
    row -= 1
    print('')
print('-' * 80)
# 第三种方式

row = 1
while row <= 9:
    col = 9
    while col >= 1:
        if row < col:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(row, col, row * col), end='')
        col -= 1
    row += 1
    print('')
print('-' * 80)

# 第四种方式
row = 9
while row >= 1:
    col = 9
    while col >= 1:
        if col > row:
            print(' ' * 8, end='')
        else:
            print('{}*{}={:<4}'.format(col, row, row * col), end='')
        col -= 1
    row -= 1
    print('')